The dopen function redirects the output from the dprintf, vdprintf and dprintmem functions to the log file named the its c-style string argument. A value of NULL may be specified to redirect output back to the console window. Note, a non-obvious side affect of redirecting output to a log file is that it will no longer be displayed in the console window unless the 'Echo log files to console' preference is checked.
Examples
To redirect all dprintf, vdprintf and dprintmem output to the file "MyApp.log":
dopen("MyApp.log");
To redirect all dprintf, vdprintf and dprintmem output back to the console window:
The dprintf family of functions produces output according to a c-style format string. The format string specifies how subsequent arguments (or arguments accessed via the variable-length argument facilities of stdarg for vdprintf and vdfprintf) are converted into output. The functions dprintf and vdprintf write output to the console window. The functions dfprintf and vdfprintf write output to the log file named by the first c-style string argument.
Examples
To output a pascal string and print its length to the log file named "debug.log":
To output a date and time in the form "Sunday, July 3, 10:02", where weekday and month are pointers to c-style strings and day, hour and min are integers:
The DCON macro allows the C preprocessor to strip all DCon function calls out of compiled code. The default behavior is to include DCon function calls, by adding a #define DCON 0 before inclusion of the DCon.h header file all DCon function calls will be converted into statements that produce no runtime code. The default behavior of the DCON macro can be altered by change its value in the DCon.h header file.
Examples
To disable DCon function calls in a single file:
#define DCON 0
#include "DCon.h"
Macro - dAssert
dAssert(conditional_expression)
Description
The dAssert macro prints an error message to the console window if the conditional_expression is false (i.e., compares equal to zero). The dAssert macro uses the dprintf function to output and is subject to the redirection effects of the dopen function. The dAssert macro only generates runtime code when the DCON macro is defined to be 1.
Examples
To generate an error message when a pointer argument is unexpectedly NULL: